package com.px.device.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.px.system.domain.AirportOsd;
import com.px.device.service.IAirportOsdService;
import com.px.framework.aes.AesSecurityParameter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 机场设备属性osdController
 * 
 * @author WRJ
 * @date 2024-08
 */
@RestController
@RequestMapping("/device/airport_osd")
public class AirportOsdController extends BaseController
{
    @Autowired
    private IAirportOsdService airportOsdService;

    /**
     * 查询机场设备属性osd列表
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:list')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(AirportOsd airportOsd)
    {
        startPage();
        List<AirportOsd> list = airportOsdService.selectAirportOsdList(airportOsd);
        return getDataTable(list);
    }

    /**
     * 导出机场设备属性osd列表
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:export')")
    @Log(title = "机场设备属性osd", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter
    public void export(HttpServletResponse response, AirportOsd airportOsd)
    {
        List<AirportOsd> list = airportOsdService.selectAirportOsdList(airportOsd);
        ExcelUtil<AirportOsd> util = new ExcelUtil<AirportOsd>(AirportOsd.class);
        util.exportExcel(response, list, "机场设备属性osd数据");
    }

    /**
     * 获取机场设备属性osd详细信息
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:query')")
    @GetMapping(value = "/{sn}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("sn") String sn)
    {
        return success(airportOsdService.selectAirportOsdBySn(sn));
    }

    /**
     * 新增机场设备属性osd
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:add')")
    @Log(title = "机场设备属性osd", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody AirportOsd airportOsd)
    {
        return toAjax(airportOsdService.insertAirportOsd(airportOsd));
    }

    /**
     * 修改机场设备属性osd
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:edit')")
    @Log(title = "机场设备属性osd", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody AirportOsd airportOsd)
    {
        return toAjax(airportOsdService.updateAirportOsd(airportOsd));
    }

    /**
     * 删除机场设备属性osd
     */
    @PreAuthorize("@ss.hasPermi('device:airport_osd:remove')")
    @Log(title = "机场设备属性osd", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sns}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable String[] sns)
    {
        return toAjax(airportOsdService.deleteAirportOsdBySns(sns));
    }
}
